﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Compiler
{
    class UserData
    {
        public List<string> IdentiferList;
        public List<string> UserCommand;
        public List<string> Usertokens;
        public List<string> UserCode;
        public List<string> Currentline;
        public int CurrentLinenum;

        public int Get_CurrentLinenum
        {
            get
            {
                return CurrentLinenum;
            }

        }
        public int CurrentWordnum;
        public UserData()
        {
            IdentiferList = new List<string>();
            UserCommand = new List<string>();
            Usertokens = new List<string>();
            UserCode = new List<string>();
            CurrentLinenum = -1;
            CurrentWordnum = 0;
        }
        
        public void incrementLinenum()
        {
            if (CurrentLinenum < UserCode.Count - 1)
            {
                CurrentLinenum++;

                Currentline = UserCode[CurrentLinenum].Split(new string[] { " " }, StringSplitOptions.None).ToList<string>();
                removeSpaces();
                //adding user tokens from user code.
                for (int i = 0; i < Currentline.Count; i++)
                    Usertokens.Add(Currentline[i]);

            }
            //else
            //{
            //    Usertokens.Add(Currentline[0]);
            //}
        }
        private void removeSpaces()
        { 
            int count = Currentline.Count;
            List<string> tempCurrentline = new List<string>();
            for (int i = 0; i < count; i++)
            {
                if (Currentline[i] != "")
                {
                    tempCurrentline.Add(Currentline[i]);
                }

            }

            Currentline = tempCurrentline;
        
        }
    }
  
}
